package cn.melonlib.cores.graphql.comp.config;

import cn.melonlib.cores.graphql.model.ext.scalars.IdType;
import cn.melonlib.cores.jpa.model.bean.collections.DataMap;
import cn.melonlib.cores.jpa.model.bean.collections.JsonMap;
import graphql.Scalars;
import graphql.schema.GraphQLScalarType;

import java.util.List;

public interface ScalarTypeConfig {

    public void init();

    public List<GraphQLScalarType> allScalarTypes();

    public GraphQLScalarType getType(Class typeCls);

    public GraphQLScalarType getType(String typeName);

    default JsonMap<GraphQLScalarType> defaultNameScalarType(){
        return JsonMap.<GraphQLScalarType>createMap().append("Int", Scalars.GraphQLInt)
                .append("Float",Scalars.GraphQLFloat)
                .append("String",Scalars.GraphQLString)
                .append("Boolean ",Scalars.GraphQLBoolean)
                .append("ID",Scalars.GraphQLID);
    }

    default DataMap<Class,GraphQLScalarType> defaultClassScalarType(){
        return new DataMap<Class,GraphQLScalarType>().append(Integer.class, Scalars.GraphQLInt)
                .append(Float.class,Scalars.GraphQLFloat).append(Double.class,Scalars.GraphQLFloat)
                .append(String.class,Scalars.GraphQLString)
                .append(Boolean.class,Scalars.GraphQLBoolean)
                .append(IdType.class,Scalars.GraphQLID);
    }
}
